<template>
  <div id="table">
    <!--<el-row>-->
      <el-input v-model="input1" style="width:200px"placeholder="请输入姓名" ></el-input>
      <el-button type="primary" @click="searchName">搜索人员</el-button>
      <el-button type="primary" @click="show">所有人员</el-button>
      <router-link  class="filter-item" to="/otherdata/createPerson">
        <el-button type="primary">添加人员</el-button>
      </router-link>
    <!--</el-row>-->
    <el-table
      :data="personTable"
      border style="width: 100%">
      <el-table-column
        prop="name"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="year"
        label="工作年限">
      </el-table-column>
      <el-table-column
        prop="process"
        label="工作流程">
      </el-table-column>
      <el-table-column
        prop="deviceCode"
        label="设备编号">
      </el-table-column>
      <el-table-column align="center" label="操作" width="200">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" icon="el-icon-edit" v-show="!scope.row.root" @click="editPeople(scope.row.name)">编辑</el-button>
          <el-button type="danger" size="mini" icon="el-icon-delete" @click="handleDelete(scope.row.name)" v-show="!scope.row.root">删除</el-button>
        </template>
      </el-table-column>
    </el-table>




  </div>
</template>

<script>
  import { page, get, get as userType, del, dels } from '@/api/sys/connSysAuthApi'
  import { parseTime } from '@/utils'
  import { req } from '@/api/base/BaseApi'
  export default {
    name: 'index',
    data() {
      return {
        module: 'peopleData',
        // table1: [],
        personTable: [],
        // testTable:[],
        input1: '',
        listLoading: true,
        listQuery: {
          page: 1,
          size: 10,
          keyword: undefined
        },
        total: 0,
        list: null
      }
    },
    mounted: function() {
      this.show()
    },
    methods: {
      get: function() {
      },
      show() {//显示所有工艺流程信息
        req('/api/sys/auth/peopleData/allList', 'POST', '').then(response => {
          this.personTable = response.data
          console.log(this.ManufactureProtable)
        }).catch(() => console.log('page request error'))
      },
      searchName() {//根据设备编号搜索
        if (this.input1 == '')
          this.show()
        else {
          req('/api/sys/auth/peopleData/name/' + this.input1, 'GET').then(response => {
            this.personTable = response.data
            console.log(this.personTable)
          }).catch(() => console.log('page request error'))
        }
      }, // end serchName
      handleDelete(name) {
        console.log(name)
        this.listLoading = true
        var st = {
          name: name
        }
        req('/api/sys/auth/peopleData/delete', 'GET', st).then(res => {
          this.show()
        }).catch(e => {
          this.listLoading = false
        })
        // del(this.module, name).then(res => {
        //   this.page()
        // }).catch(e => {
        //   this.listLoading = false
        // })
      }, // end delete
      editPeople(name) {
        this.$router.push( {path: '/otherdata/updatePerson' ,query: {name: name }})
      }
    }
  }
</script>

<style scoped>

</style>
